﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IRCServer.CommandHandlers;

namespace IRCServer.Entities.Commands
{
    class SPRIVMSGCommand : IRCCommandBase
    {
        public SPRIVMSGCommand(string message) :
            base(message)
        {
            
            this.CommandText = message;

            string[] parameters = Utilities.CommandParser.GetParameters(message);

            if (parameters.Length > 1)
            {
                this.SenderNickname = parameters[1];
            }
            if (parameters.Length > 2)
            {
                this.Target = parameters[2];
            }

            if (parameters.Length > 3)
            {
                this.Message = parameters[3];
            }
        }

        public string CommandText { get; set; }

        public string Message { get; set; }

        public string Target { get; set; }

        public string SenderNickname { get; set; }

        public override string CommandName()
        {
            return "SPRIVMSG";
        }

        public override string ExecuteCommand(SessionBase session)
        {
            SPRIVMSGCommandHandler handler = new SPRIVMSGCommandHandler();
            return handler.HandleCommand(this, session);
        }
    }
}
